<?
/**
 * Copyright 2008 Melange.
 *
 * This file is part of Melange CMS
 *
 * @package cms
 *
 */


/**
 * Requirements
 */
require_once("mvc/action/ActionForm.php");
require_once("mvc/action/ActionMessage.php");
require_once("mvc/action/ActionMessages.php");
require_once("cms/guide/om/GuideI18n.php");



/**
 * BaseGuideForm Class
 *
 * @category    Melange CMS
 * @package     cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 */
class BaseGuideForm extends ActionForm {


    // ----------------------------------------------------- Instance Variables


    /**
     * guideI18n
     *
     * @var GuideI18n 
     */
    protected $guideI18n;


    /**
     * formImage
     *
     * @var mixed 
     */
    protected $formImage;


    /**
     * deleteImage
     *
     * @var mixed 
     */
    protected $deleteImage;


    // ----------------------------------------------------------- Constructors


    /**
     * Construct new BaseGuideForm
     */
    public function __construct() {
        $this->guideI18n = new GuideI18n();
        $this->formImage = null;
        $this->deleteImage = false;
    }


    // ------------------------------------------------------------- Properties


    /**
     * Get GuideI18n
     *
     * @return GuideI18n 
     */
    public function getGuideI18n() {
        return $this->guideI18n;
    }


    /**
     * Set GuideI18n
     *
     * @param GuideI18n  guideI18n
     */
    public function setGuideI18n(GuideI18n $guideI18n) {
        $this->guideI18n = $guideI18n;
    }


    /**
     * Get FormImage
     *
     * @return mixed 
     */
    public function getFormImage() {
        return $this->formImage;
    }


    /**
     * Set FormImage
     *
     * @param mixed  formImage
     */
    public function setFormImage($formImage) {
        $this->formImage = $formImage;
    }


    /**
     * Get DeleteImage
     *
     * @return mixed 
     */
    public function getDeleteImage() {
        return $this->deleteImage;
    }


    /**
     * Set DeleteImage
     *
     * @param mixed  deleteImage
     */
    public function setDeleteImage($deleteImage) {
        $this->deleteImage = $deleteImage;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Validate this form
     *
     * @return array $errors
     */
    public function validate() {

        $errors = new ActionMessages();

        if(is_null($this->getGuideI18n()->getDescription1()) || strlen($this->getGuideI18n()->getDescription1()) == 0)
            $errors->add("guideI18n->description1",
                new ActionMessage("errors.required", true, new ActionMessage("prompt.info", true)));


        if(is_null($this->getGuideI18n()->getDescription2()) || strlen($this->getGuideI18n()->getDescription2()) == 0)
            $errors->add("guideI18n->description2",
                new ActionMessage("errors.required", true, new ActionMessage("prompt.un", true)));


        global $ALLOWABLE_IMAGES;
        if(!is_null($this->getFormImage()) && isset($this->formImage["size"]) && $this->formImage["size"] > 0 && !array_key_exists($this->formImage["type"], $ALLOWABLE_IMAGES))
            $errors->add("formImage",
                new ActionMessage("errors.image", true, new ActionMessage("prompt.image", true)));

        return $errors;
    }

}
?>